<html>
<head><meta charset="utf-8"><title>generic data dependency vs. arrays · project-const-generics · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/index.html">project-const-generics</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html">generic data dependency vs. arrays</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="225192619"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/225192619" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#225192619">(Feb 04 2021 at 17:24)</a>:</h4>
<p>Const generics can't depend on other generics as input parameters as of now, but is/will it be possible to have a const array as an input with a parameterized size and have the output of the function follow the input size?</p>



<a name="225192727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/225192727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#225192727">(Feb 04 2021 at 17:24)</a>:</h4>
<p>yeah, we're working on this under the <code>const_evaluatable_checked</code> feature gate</p>



<a name="225192794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/225192794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#225192794">(Feb 04 2021 at 17:25)</a>:</h4>
<p>aha! nice. I figured that was already in the works somewhere but I wanted to check that I wasn't like losing my mind.</p>



<a name="225217147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/225217147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#225217147">(Feb 04 2021 at 20:22)</a>:</h4>
<p>So I figure I would elaborate a bit, since seeing the use case might inform or help?<br>
I am wanting to write something like</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">LEN</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="n">SimdType</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">LEN</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="k">fn</span> <span class="nf">shuffle</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">M</span>: <span class="p">[</span><span class="kt">u32</span><span class="p">;</span><span class="w"> </span><span class="n">S</span><span class="p">],</span><span class="w"> </span><span class="k">const</span><span class="w"> </span><span class="n">S</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="n">other</span>: <span class="nc">Self</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="nc">Self</span><span class="o">&lt;</span><span class="n">S</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">      </span><span class="cm">/* some SIMD stuff */</span><span class="w"></span>
<span class="w">  </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="c1">// Actual usage would look like...</span>
<span class="kd">let</span><span class="w"> </span><span class="n">v1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">SimdType</span>::<span class="n">new</span><span class="p">([</span><span class="o">-</span><span class="mf">1.1</span><span class="p">,</span><span class="w"> </span><span class="n">NaN</span><span class="p">,</span><span class="w"> </span><span class="mf">22.0</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mi">0</span><span class="p">]);</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">v2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">SimdType</span>::<span class="n">new</span><span class="p">([</span><span class="mf">33.0</span><span class="p">,</span><span class="w"> </span><span class="o">-</span><span class="mf">123.4</span><span class="p">,</span><span class="w"> </span><span class="n">NaN</span><span class="p">,</span><span class="w"> </span><span class="mf">9000.1</span><span class="p">]);</span><span class="w"></span>

<span class="n">v1</span><span class="p">.</span><span class="n">shuffle</span><span class="o">&lt;</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="mi">7</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">]</span><span class="o">&gt;</span><span class="p">(</span><span class="n">v2</span><span class="p">)</span><span class="w"></span>
</code></pre></div>
<p>is something that pretty, where S is implied from M, completely unrealistic?</p>



<a name="225220648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/225220648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#225220648">(Feb 04 2021 at 20:52)</a>:</h4>
<p>ah, you want a generic const parameter type :/</p>



<a name="225220743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/225220743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#225220743">(Feb 04 2021 at 20:52)</a>:</h4>
<p>(the type of <code>M</code> here)</p>



<a name="225220760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/225220760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#225220760">(Feb 04 2021 at 20:52)</a>:</h4>
<p>that's not currently getting worked on</p>



<a name="225220798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/225220798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#225220798">(Feb 04 2021 at 20:53)</a>:</h4>
<p>it's desired but kind of hard so that will take quite a while</p>



<a name="225221290"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/225221290" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#225221290">(Feb 04 2021 at 20:57)</a>:</h4>
<p>Oof, okay!</p>



<a name="225221680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/225221680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#225221680">(Feb 04 2021 at 21:00)</a>:</h4>
<p>...OK so I am curious about this then, because that's exactly how <code>simd_shuffle{N}</code> works, ne?<br>
to be blunt, is the brutal hack for making simd_shuffle work actually that unsound?<br>
or, hm, I suppose it's the fn names that make it work...</p>



<a name="225225923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/225225923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#225225923">(Feb 04 2021 at 21:32)</a>:</h4>
<p>the issue is not that there's anything unsound here</p>



<a name="225225943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/225225943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#225225943">(Feb 04 2021 at 21:32)</a>:</h4>
<p>i think it's mostly an implementation hurdle</p>



<a name="225225961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/225225961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#225225961">(Feb 04 2021 at 21:32)</a>:</h4>
<p>don't remember why we originally forbid it</p>



<a name="225225984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/225225984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#225225984">(Feb 04 2021 at 21:33)</a>:</h4>
<p>could try to remove that restriction and see where it breaks ^^</p>



<a name="225226058"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/225226058" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#225226058">(Feb 04 2021 at 21:33)</a>:</h4>
<p>i think the issue was hard to deal with, but that was a few months ago</p>



<a name="225226320"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/225226320" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#225226320">(Feb 04 2021 at 21:35)</a>:</h4>
<p>you already have a working method <code>simd_shuffle</code>?</p>



<a name="225226990"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/225226990" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#225226990">(Feb 04 2021 at 21:39)</a>:</h4>
<p>well, what Rust has is an extern "platform-intrinsic" called <code>simd_shuffle{N}</code> where N is whatever number... so thinking about it, it probably is mostly guaranteed by the fact that a specific identifier is invoked, and each is its own case. However, I've seen the code for typechecking these functions, and they're kind of all treated as the same function internally... the typechecker basically just verifies the numbers are lined up between the name and the array length, which, I think for the <strong>general</strong> case this might be hard, but I think for "make sure a const <strong>array</strong> works like this" it might be plausible to do this more easily?</p>



<a name="225376491"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/225376491" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#225376491">(Feb 06 2021 at 00:37)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays/near/225225984">said</a>:</p>
<blockquote>
<p>could try to remove that restriction and see where it breaks ^^</p>
</blockquote>
<p>looked into this together with <span class="user-mention" data-user-id="326176">@Boxy</span>  and remembered why i added this restriction <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> wrote it down in <a href="https://github.com/rust-lang/project-const-generics/pull/3">https://github.com/rust-lang/project-const-generics/pull/3</a> so that this doesn't happen again in the future.</p>
<p>This explanation requires some knowledge about the query and type system so it might not be too helpful to you <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="225377047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/225377047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#225377047">(Feb 06 2021 at 00:48)</a>:</h4>
<p>no this is interesting. <span aria-label="eyes" class="emoji emoji-1f440" role="img" title="eyes">:eyes:</span> I understand where this is going a bit.</p>



<a name="238540055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/238540055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#238540055">(May 12 2021 at 20:34)</a>:</h4>
<p>Using a const generic parameter internally for <code>simd_shuffle{N}</code> came up here, and I asked whether or not this would smooth the path towards it, and people seem to think it might be workable? <a href="https://github.com/rust-lang/rust/issues/85229">https://github.com/rust-lang/rust/issues/85229</a><br>
Figured I'd check up on what's what.</p>



<a name="238540164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/238540164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#238540164">(May 12 2021 at 20:35)</a>:</h4>
<p>Apparently the StructuralEq of it matters?</p>



<a name="238540295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/238540295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#238540295">(May 12 2021 at 20:35)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="124288">@oli</span> since I dug up the relevant Zulip thread.</p>



<a name="238550167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/238550167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#238550167">(May 12 2021 at 21:52)</a>:</h4>
<p>Oof, I read the pr by lcnr above...</p>



<a name="238550240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/238550240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#238550240">(May 12 2021 at 21:52)</a>:</h4>
<p>Seems a bit messy on the query system side</p>



<a name="238550354"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/238550354" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#238550354">(May 12 2021 at 21:53)</a>:</h4>
<p>What if we only accepted monomorphic integer types for now? Then the additional substs arg would never have different types for the same arg</p>



<a name="238560582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/238560582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#238560582">(May 12 2021 at 23:47)</a>:</h4>
<p>Hrm, I am not sure what you mean by a "monomorphic integer type"  here. I am definitely fine for my use case if it does nothing special, however, and groks this const generic parameterization here in the most basic, obvious way, without further wiggle room or cleverness... that would remove what I consider to be an ugly hack.</p>



<a name="238561488"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/238561488" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#238561488">(May 12 2021 at 23:57)</a>:</h4>
<p>I mean that we don't allow generic types in the types of const generics, but only other const generics, and only those of integer types</p>



<a name="238561497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/238561497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#238561497">(May 12 2021 at 23:57)</a>:</h4>
<p>That would cover the array use case</p>



<a name="238565441"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/238565441" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#238565441">(May 13 2021 at 00:44)</a>:</h4>
<p>Oh yeah! That's fine, in practice I mostly am going to make use of const generic integer arrays. Anything more complicated is more of a "nice to have" and not "this would remove an ugly hack".</p>



<a name="238586804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/238586804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#238586804">(May 13 2021 at 06:32)</a>:</h4>
<p>For this specific case... what if we used a slice instead of an array and picked up the length from the const slice? It's a bit riddiculous, but we can always change it to an array again once const generic parameter's types can be generic themselves</p>



<a name="238726009"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/238726009" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#238726009">(May 14 2021 at 06:51)</a>:</h4>
<p>That's probably fine as long as all the vectors involved get validated for length equality.</p>



<a name="238727409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/238727409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#238727409">(May 14 2021 at 07:10)</a>:</h4>
<p>hmm, you <em>should</em> be able to have different input and output vector lengths for shuffle... e.g. in GLSL you can do:</p>
<div class="codehilite" data-code-language="GLSL"><pre><span></span><code><span class="kt">vec4</span> <span class="n">a</span><span class="p">;</span>
<span class="kt">vec2</span> <span class="n">b</span> <span class="o">=</span> <span class="n">a</span><span class="p">.</span><span class="n">xz</span><span class="p">;</span> <span class="c1">// get first and third element of a</span>
</code></pre></div>



<a name="238730226"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/238730226" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#238730226">(May 14 2021 at 07:39)</a>:</h4>
<p>True but not terribly important for the internal API.</p>



<a name="238836060"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/260443-project-const-generics/topic/generic%20data%20dependency%20vs.%20arrays/near/238836060" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Lifshay <a href="https://rust-lang.github.io/zulip_archive/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays.html#238836060">(May 14 2021 at 22:06)</a>:</h4>
<p><span class="user-mention silent" data-user-id="281757">Jubilee</span> <a href="#narrow/stream/260443-project-const-generics/topic/generic.20data.20dependency.20vs.2E.20arrays/near/238730226">said</a>:</p>
<blockquote>
<p>True but not terribly important for the internal API.</p>
</blockquote>
<p>whoops, thought this was project-portable-simd</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>